<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>员工列表</title>
    <script th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>
    <script>
        $(function () {
          //绑定删除链接
            $(".delete").click(function () {
                if (confirm("您确定删除吗!")){
                    $("#f1").attr("action",this.href).submit();
                }
                //删除,提交表单f1

                //屏蔽超链接的默认跳转
                return false;
            })
        })
    </script>
    <style>
        h1{
            text-align: center;
        }
        table{
            width: 700px;
            text-align: center;
            border-collapse: collapse;
            margin: 0 auto;
            border: 1px solid black;

        }
        td,th{
            border: 1px solid ;
            line-height: 35px;
        }
        tr:nth-child(odd){
            background-color: yellow;
        }
        tr:hover{
            background-color: greenyellow;
            cursor: pointer;
        }
        #p1{

            width: 700px;
            text-align: right;
            margin: 0 auto;
        }

    </style>
</head>
<body>
<h1>员工列表</h1>
<p id="p1">
    <a th:href="@{/emp/ui}" >新增</a>
</p>
<table>
    <tr>
        <th>员工编号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>年龄</th>
        <th>生日</th>
        <th>证件类型</th>
        <th>操作</th>
    </tr>
    <tr th:each="emp:${empList}">
        <td th:text="${emp.id}"></td>
        <td th:text="${emp.name}"></td>
        <td th:text="${emp.sex}"></td>
        <td th:text="${emp.age}"></td>
        <td th:text="${#calendars.format(emp.birthday,'yyyy-MM-dd')}"></td>
        <td th:text="${emp.idType}"></td>
        <td>
            <a th:href="@{'/emp/'+${emp.id}}">修改</a>
            |
            <a class="delete" th:href="@{'/emp/'+${emp.id}}">删除</a>
        </td>

    </tr>
</table>
</body>
<form id="f1" method="post">
    <input type="hidden" name="_method" value="DELETE">
</form>
</html>